package useFn;

public class demo4 {
    public static void main(String[] args) throws InterruptedException {
        // 正常方式
        myRunable myRunable = new myRunable();
        Thread thread = new Thread(myRunable);
        thread.setPriority(10);
        thread.start();

        // 匿名内部类
        Thread thread1 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("1");
            }
        });
        System.out.println(thread1.getPriority());

        // 函数式接口的 lambda
        Thread thread2 = new Thread(() -> System.out.println("1"));
        thread2.start();
        System.out.println(thread2.getPriority());


    }
}
class myRunable implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i < 200; i++) {
            System.out.println(Thread.currentThread().getName()+"---"+i);
        }
    }
}
